package org.mathig.poker;

/**
 * Rank of a Card (A, K, Q, T, 9...).
 * 
 * @author mathig
 * @see Card
 */
public enum Rank {
	TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6), SEVEN(7), EIGHT(8), NINE(9), TEN(10), JACK(11), QUEEN(12), KING(13), ACE(14);

	private String code;

	private String name;

	private int number;

	private Rank(int number) {
		this.number = number;

		if (number < 10)
			this.code = String.valueOf(number);
		else
			this.code = String.valueOf(this.name().charAt(0));

		this.name = name().charAt(0) + name().substring(1).toLowerCase();
	}

	@Override
	public String toString() {
		return code;
	}

	public String getCode() {
		return code;
	}

	public String getName() {
		return name;
	}

	public boolean isGreaterThan(Rank rank) {
		return this.ordinal() > rank.ordinal();
	}

	public boolean isLowerThan(Rank rank) {
		return this.ordinal() < rank.ordinal();
	}

	public boolean isFigure() {
		return this.ordinal() >= JACK.ordinal();
	}

	public int getNumber() {
		return number;
	}

}
